ept: Remove lock in ept_get_entry, replace with access-once semantics.
authorKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:47:05 +0000 (10:47 +0000)
committerKeir Fraser <keir@xen.org>
Wed, 15 Dec 2010 10:47:05 +0000 (10:47 +0000)
commite28218a339349c04ec5912ec10faaa6cca065dea
tree3e5ae15eae236123a4d3155d4f3664ed6654d168
parentb406d3e356621425853fed553bd3808ecfcba852
ept: Remove lock in ept_get_entry, replace with access-once semantics.

This mirrors the RVI/shadow situation, where p2m read access is
lockless because it's done in the hardware (linear map of the p2m
table).

This fixes the original bug (call it bug A) without introducing bug B
(a deadlock).

Bug A was caused by a race when updating p2m entries: between testing
if it's valid, and testing if it's populate-on-demand, it may have
been changed from populate-on-demand to valid.

My original patch simply introduced a lock into ept_get_entry, but
that caused bug B, caused by circular locking order: p2m_change_type
[grabs p2m lock] -> set_p2m_entry -> ept_set_entry ->
ept_set_middle_level -> p2m_alloc [grabs hap lock] write cr4 ->
hap_update_paging_modes [grabes hap lock] -> hap_update_cr3 ->
gfn_to_mfn -> ept_get_entry -> [grabs p2m lock]

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/arch/x86/mm/hap/p2m-ept.c